// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 导入全局样式表
import './assets/css/global.css'
// 引入第三方图标库
import './assets/icon/iconfont.css'
import ZkTable from 'vue-table-with-tree-grid'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本编辑器的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
// // 全局引入echarts
// import echarts from 'echarts'
var axios = require('axios')
axios.defaults.baseURL = 'http://127.0.0.1:8082/'
// Vue.prototype.$http = axios
Vue.prototype.$axios = axios
// Vue.prototype.$echarts = echarts
axios.interceptors.request.use(config => {
  // config.headers为请求头对象，添加Token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.use(ElementUI)
Vue.use(ZkTable)
Vue.use(VueQuillEditor)
// 定义一个日期过滤器
Vue.filter('dataFormat', function (originalData) {
  const dt = new Date(originalData)
  const yy = dt.getFullYear()
  const mm = (dt.getMonth() + 1 + '').padStart(2, '0')
  const dd = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const min = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // 返回一个模板字符串
  return `${yy}-${mm}-${dd} ${hh}:${min}:${ss}`
})
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
